package com.tencent.sr.iris.basic.saas.dependency.poster;

import com.alibaba.fastjson.JSON;
import com.tencent.sr.iris.basic.service.interfaces.client.poster.InvitePosterManageClient;
import com.tencent.sr.iris.basic.service.interfaces.request.poster.AddOrUpdateInvitePosterRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.poster.InvitePosterCommonRequest;
import com.tencent.sr.iris.basic.service.interfaces.request.poster.InvitePosterMoveRequest;
import com.tencent.sr.iris.basic.service.interfaces.response.poster.InvitePosterDetailResponse;
import com.tencent.sr.iris.basic.service.interfaces.response.poster.InvitePosterListResponse;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.common.request.PaginationRequest;
import com.tencent.sr.rmall.common.response.PaginationResponse;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class InvitePosterManageDependency {

    @Resource
    private InvitePosterManageClient invitePosterManageClient;

    public HttpResult<Boolean> save(AddOrUpdateInvitePosterRequest request) {
        try {
            return invitePosterManageClient.save(request);
        } catch (Exception e) {
            log.error("save invitePoster scene error,request:{}", JSON.toJSONString(request), e);
            return HttpResult.fail(e.getMessage());
        }
    }

    public HttpResult<Boolean> update(AddOrUpdateInvitePosterRequest request) {
        try {
            return invitePosterManageClient.update(request);
        } catch (Exception e) {
            log.error("update invitePoster scene error,request:{}", JSON.toJSONString(request), e);
            return HttpResult.fail(e.getMessage());
        }
    }

    public HttpResult<Boolean> delete(InvitePosterCommonRequest request) {
        try {
            return invitePosterManageClient.delete(request);
        } catch (Exception e) {
            log.error("delete invitePoster scene error,request:{}", JSON.toJSONString(request), e);
            return HttpResult.fail(e.getMessage());
        }
    }

    public HttpResult<InvitePosterDetailResponse> detail(InvitePosterCommonRequest request) {
        try {
            return invitePosterManageClient.detail(request);
        } catch (Exception e) {
            log.error("query invitePoster scene detail error,request:{}", JSON.toJSONString(request), e);
            return HttpResult.fail(e.getMessage());
        }
    }

    public HttpResult<PaginationResponse<InvitePosterListResponse>> list(
            PaginationRequest<InvitePosterCommonRequest> request) {
        try {
            return invitePosterManageClient.list(request);
        } catch (Exception e) {
            log.error("query invitePoster scene list error,request:{}", JSON.toJSONString(request), e);
            return HttpResult.fail(e.getMessage());
        }
    }

    public HttpResult<Boolean> move(InvitePosterMoveRequest request) {
        try {
            return invitePosterManageClient.move(request);
        } catch (Exception e) {
            log.error("move invitePoster scene error,request:{}", JSON.toJSONString(request), e);
            return HttpResult.fail(e.getMessage());
        }
    }
}
